<?php if ($user->getId()): ?>
    <?php $galleryItem = $user->getProfilePhoto()->getGalleryItem() ?>
<?php endif; ?>
<?php echo image_tag("/uploads/gallery/" . $galleryItem->getId() . "/" . $galleryItem->getPhotoUrl($height), array("class" => "profile-photo", "alt" => $galleryItem->getCaption(), "height" => $height . "px")) ?>